<?
layout("/inc/layout.html",{title:sysTitle}){
?>

<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">充值管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>数字资源统一交易管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">充值管理</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">
		<div class="row mbl">
			<div class="col-lg-10">
				<div class="input-group input-group-sm mbs">
					<table style="width: 95%;margin-top: 20px;">
						<tr height="50">
							 <td align="right" style="width: 100px;">昵称&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="nickname" name="nickname" /></td> 
							<td align="right" style="width: 100px;">用户名&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="username" name="username" /></td>
							<td align="right" style="width: 100px;">真实姓名&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="realname" name="realname" /></td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
							<td align="right" style="width: 100px;">
								<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="queryUser(1)">模糊查询</button>
								&nbsp;&nbsp;
							</td>
							<td align="right" style="width: 100px;">
								<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="queryUser(0)">精确查询</button>
								&nbsp;&nbsp;
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
		<div class="row mbl" id="data_list">
		
		 <div style="text-align: center; margin-top: 6%;">
		 	<img src="images/pay_banner.jpeg" />
		 </div>
		 <!--	<div class="col-md-6">
	            <div class="panel" style="background-color: #FFFAF0;">
	                <div class="panel-body pan">
	                    <div class="profile" style="width: 95%;">
	                        <div class="user-info">
	                            <div style="margin-bottom: -15px" class="row">
	                                <div class="col-xs-12 col-sm-8">
	                                		<table style="width: 100%;">
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">用户名：</td>
	                                    		<td>anhuifeng</td>
	                                    		<td style="text-align: right;">昵称：</td>
	                                    		<td>机智的小安</td>
	                                    	</tr>
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">真实姓名：</td>
	                                    		<td>安会锋</td>
	                                    		<td style="text-align: right;">手机号：</td>
	                                    		<td>15652301163</td>
	                                    	</tr>
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">邮箱：</td>
	                                    		<td colspan="3">wanm100@vip.qq.com</td>
	                                    	</tr>
	                                    	<tr height="65">
	                                    		<td style="text-align: right; font-size: 22px;">充值金额：</td>
	                                    		<td colspan="3">
	                                    			<input type="text" class="form-control" placeholder="0.00" 
	                                    				style="width: 100px;float: left;line-height: 22px; height: 45px;font-size: 16px; padding: 16px 4px;"
	                                    				id="" name="" />
	                                    			<button class="btn btn-lg btn-primary" style="float: left; margin-left: 10px;" onclick="">充值</button>
	                                    		</td>
	                                    	</tr>
	                                    	<tr height="35">
	                                    		<td>&nbsp;</td>
	                                    		<td colspan="3">
	                                    			100代表加钱，-100代表减钱。 
	                                    		</td>
	                                    	</tr>
	                                    	</table>
	                                </div>
	                                <div class="col-xs-12 col-sm-4 text-left" style="font-size: 15px;color: #ff7f00;">
	                                    <table style="width: 100%;">
	                                    	<tr style="text-align: right;height: 35px;">
	                                    		<td>当前余额：</td>
	                                    		<td>99999.00</td>
	                                    	</tr>
	                                    	<tr style="text-align: right;height: 35px;">
	                                    		<td>已支付金额：</td>
	                                    		<td>9999.00</td>
	                                    	</tr>
	                                    	<tr style="text-align: center;line-height: 45px;">
	                                    		<td colspan="2">
	                                    			<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="get()">充值历史查询</button>
	                                    		</td>
	                                    	</tr>
	                                    </table>
	                                </div>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
	        </div>
	        
	        <div class="col-md-6">
	            <div class="panel" style="background-color: #FFFAF0;">
	                <div class="panel-body pan">
	                    <div class="profile" style="width: 95%;">
	                        <div class="user-info">
	                            <div style="margin-bottom: -15px" class="row">
	                                <div class="col-xs-12 col-sm-8">
	                                		<table style="width: 100%;">
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">用户名：</td>
	                                    		<td>anhuifeng</td>
	                                    		<td style="text-align: right;">昵称：</td>
	                                    		<td>机智的小安</td>
	                                    	</tr>
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">真实姓名：</td>
	                                    		<td>安会锋</td>
	                                    		<td style="text-align: right;">手机号：</td>
	                                    		<td>15652301163</td>
	                                    	</tr>
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">邮箱：</td>
	                                    		<td colspan="3">wanm100@vip.qq.com</td>
	                                    	</tr>
	                                    	<tr height="65">
	                                    		<td style="text-align: right; font-size: 22px;">充值金额：</td>
	                                    		<td colspan="3">
	                                    			<input type="text" class="form-control" placeholder="0.00" 
	                                    				style="width: 100px;float: left;line-height: 22px; height: 45px;font-size: 16px; padding: 16px 4px;"
	                                    				id="" name="" />
	                                    			<button class="btn btn-lg btn-primary" style="float: left; margin-left: 10px;" onclick="">充值</button>
	                                    		</td>
	                                    	</tr>
	                                    	<tr height="35">
	                                    		<td>&nbsp;</td>
	                                    		<td colspan="3">
	                                    			100代表加钱，-100代表减钱。 
	                                    		</td>
	                                    	</tr>
	                                    	</table>
	                                </div>
	                                <div class="col-xs-12 col-sm-4 text-left" style="font-size: 15px;color: #ff7f00;">
	                                    <table style="width: 100%;">
	                                    	<tr style="text-align: right;height: 35px;">
	                                    		<td>当前余额：</td>
	                                    		<td>99999.00</td>
	                                    	</tr>
	                                    	<tr style="text-align: right;height: 35px;">
	                                    		<td>已支付金额：</td>
	                                    		<td>9999.00</td>
	                                    	</tr>
	                                    	<tr style="text-align: center;line-height: 45px;">
	                                    		<td colspan="2">
	                                    			<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="get()">充值历史查询</button>
	                                    		</td>
	                                    	</tr>
	                                    </table>
	                                </div>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
	        </div>
	        
	        <div class="col-md-6">
	            <div class="panel" style="background-color: #FFFAF0;">
	                <div class="panel-body pan">
	                    <div class="profile" style="width: 95%;">
	                        <div class="user-info">
	                            <div style="margin-bottom: -15px" class="row">
	                                <div class="col-xs-12 col-sm-8">
	                                		<table style="width: 100%;">
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">用户名：</td>
	                                    		<td>anhuifeng</td>
	                                    		<td style="text-align: right;">昵称：</td>
	                                    		<td>机智的小安</td>
	                                    	</tr>
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">真实姓名：</td>
	                                    		<td>安会锋</td>
	                                    		<td style="text-align: right;">手机号：</td>
	                                    		<td>15652301163</td>
	                                    	</tr>
	                                    	<tr height="45">
	                                    		<td style="text-align: right;">邮箱：</td>
	                                    		<td colspan="3">wanm100@vip.qq.com</td>
	                                    	</tr>
	                                    	<tr height="65">
	                                    		<td style="text-align: right; font-size: 22px;">充值金额：</td>
	                                    		<td colspan="3">
	                                    			<input type="text" class="form-control" placeholder="0.00" 
	                                    				style="width: 100px;float: left;line-height: 22px; height: 45px;font-size: 16px; padding: 16px 4px;"
	                                    				id="" name="" />
	                                    			<button class="btn btn-lg btn-primary" style="float: left; margin-left: 10px;" onclick="">充值</button>
	                                    		</td>
	                                    	</tr>
	                                    	<tr height="35">
	                                    		<td>&nbsp;</td>
	                                    		<td colspan="3">
	                                    			100代表加钱，-100代表减钱。 
	                                    		</td>
	                                    	</tr>
	                                    	</table>
	                                </div>
	                                <div class="col-xs-12 col-sm-4 text-left" style="font-size: 15px;color: #ff7f00;">
	                                    <table style="width: 100%;">
	                                    	<tr style="text-align: right;height: 35px;">
	                                    		<td>当前余额：</td>
	                                    		<td>99999.00</td>
	                                    	</tr>
	                                    	<tr style="text-align: right;height: 35px;">
	                                    		<td>已支付金额：</td>
	                                    		<td>9999.00</td>
	                                    	</tr>
	                                    	<tr style="text-align: center;line-height: 45px;">
	                                    		<td colspan="2">
	                                    			<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="get()">充值历史查询</button>
	                                    		</td>
	                                    	</tr>
	                                    </table>
	                                </div>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
	        </div> -->
		</div>
	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script type="text/javascript">
	function queryUser(type){
		if($("#username").val() == '' && $("#nickname").val() == '' && $("#realname").val()==''){
			alert('筛选条件不能为空！');
			return null;
		}
		$.ajax({
			type : "post",
			url : "queryRecharge.do",
			data : {
				"username" : $("#username").val(),
				"nickname" : $("#nickname").val(),
				"realname" : $("#realname").val(),
				"type":type
			},
			dataType : "json",
			async : false,
			success : function(data) {
				var src='';
				for(var i=0;i<data.length;i++){
					src +='<div class="col-md-6">'
			            +'<div class="panel" style="background-color: #FFFAF0;">'
			            +'<div class="panel-body pan">'
			            +'<div class="profile" style="width: 95%;">'
			            +'<div class="user-info">'
			            +'<div style="margin-bottom: -15px" class="row">'
			            +'<div class="col-xs-12 col-sm-8">'
			            +'<table style="width: 100%;">'
			            +'<tr height="45">'
			            +'<td style="text-align: right;">用户名：</td>'
			            +'<td>'+data[i].username+'</td>'
			            +'<td style="text-align: right;">昵称：</td>'
			            +'<td>'+data[i].nickname+'</td>'
			            +'</tr>'
			            +'<tr height="45">'
			            +'<td style="text-align: right;">真实姓名：</td>'
			            +'<td>'+data[i].realname+'</td>'
			            +'<td style="text-align: right;">手机号：</td>'
			            +'<td>'+data[i].mobilephone+'</td>'
			            +'</tr>'
			            +'<tr height="45">'
			            +'<td style="text-align: right;">邮箱：</td>'
			            +'<td colspan="3">'+data[i].email+'</td>'
			            +'</tr>'
			            +'<tr height="65">'
			            +'<td style="text-align: right; font-size: 22px;">充值金额：</td>'
			            +'<td colspan="3">'
			            +'<input type="text" class="form-control" placeholder="0.00" style="width: 100px;float: left;line-height: 22px; height: 45px;font-size: 16px; padding: 16px 4px;" id="money_'+data[i].id+'" name="money_'+data[i].id+'" />'
			            +'<button class="btn btn-lg btn-primary" style="float: left; margin-left: 10px;" onclick="saveMoney('+data[i].id+','+type+')">充值</button>'
			            +'</td>'
			            +'</tr>'
			            +'<tr height="35">'
			            +'<td>&nbsp;</td>'
			            +'<td colspan="3">'
			            +'100代表加钱，-100代表减钱。 '
			            +'</td>'
			            +'</tr>'
			            +'</table>'
			            +'</div>'
			            +'<div class="col-xs-12 col-sm-4 text-left" style="font-size: 15px;color: #ff7f00;">'
			            +'<table style="width: 100%;">'
			            +'<tr style="text-align: right;height: 35px;">'
			            +'<td>当前余额：</td>'
			            +'<td>'+data[i].balance+'</td>'
			            +'</tr>'
			            +'<tr style="text-align: right;height: 35px;">'
			            +'<td>已支付金额：</td>'
			            +'<td>'+data[i].payment+'</td>'
			            +'</tr>'
			            +'<tr style="text-align: center;line-height: 45px;">'
			            +'<td colspan="2">'
			            +'<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="history('+data[i].id+')">充值历史查询</button>'
			            +'</td>'
			            +'</tr>'
			            +'</table>'
			            +'</div>'
			            +'</div>'
			            +'</div>'
			            +'</div>'
			            +'</div>'
			            +'</div>'
			        	+'</div>';
				}
				if(src != ''){
					$("#data_list").html(src)
				}else{
					$("#data_list").html('<div style="margin-top: 5px;padding-top: 250px;text-align: center;font-size: 30px;">抱歉！未找到用户...</div>');
				}
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}
	function saveMoney(id,type){
	var saveMoney = $("#money_"+id).val();
	if ($.trim($("#money_"+id).val()).length < 1) {
		alert('请输入充值金额！');
		return null;
	}
	var reg = /^[+-]?\d*\.?\d{0,2}$/;  
	 if(!reg.test(saveMoney)){
	 	alert('金额只能是整数、负数！小数点最多保留二位');
	 	$("#money_"+id).val("");
		return null;
	 }
	if (confirm("是否确认充值！！")) {
		$.ajax({
			type : "post",
			url : "saveMoney.do",
			data : {
				"money" : $("#money_"+id).val(),
				"id":id
			},
			dataType : "json",
			async : false,
			success : function(data) {
				if(data == 'yes'){
					layer.msg('充值成功!');
				}
				if(data == 'no'){
					layer.msg('充值失败!');
				}
				if(data == 'error'){
					layer.msg('账户余额为0!');
				}
				queryUser(type)
			},
			error : function(data) {
				alert("请求失败");
			}
		});
		}
	}
	var userNmaeId;
	function getUserNmaeId( ) {  
         return userNmaeId;
    }
	function history(userid){
		userNmaeId = userid;
		layer.open({
			type : 2,
			area : [ '1050px', '630px' ],
			title:"充值历史",
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			move : false,
			skin : 'layui-layer-rim', //加上边框
			btn : ['关闭' ],
			content : "pay-organization-recharge-history.html",
		});
	}
</script>